
 ( define gen )
 ( define entered 0 )
 ( define size 1 )
 ( define elmts )
 ( define temp 0 )

 ( define R
   ( lambda ( )
     ( display "Enter Number Of Elements : " )
     ( set! size ( read ) )
     ( set! elmts ( make-vector size ) )
     ( newline )

     ( do
       ( ( i 0 ( + i 1 ) )
        )
       ( ( = i size ) ( display "" )
        )
       ( display "     Enter Element No [" )
       ( display i )
       ( display "] " )
       ( vector-set! elmts i ( read ) )
       ( newline )
      )
     ( set! entered 1 )
    )
  )

 ( define Q
   ( lambda ( start end )
     ( define temp 0 )
     ( define low start )
     ( define high end )
     ( define list-sep  ( vector-ref elmts ( quotient ( + start end ) 2 ) ) )

     ( display "elements->" )
     ( display elmts )
     ( newline )

     ( display "list-sep->" )
     ( display list-sep )
     ( newline )

     ( display "Q U I C K   S O R T" )
     ( newline )

     ( if ( = entered 0 )
        ( begin
          ( display "THE ARRAY IS EMPTY" )
         )
       ( begin
         ( do
           ( )
           ( ( > low high ) )
           ( do
             ( )
             ( ( >= ( vector-ref elmts low ) list-sep ) )
             ( ( set! low ( + low 1 ) )
              )
            )
           ( do
             ( )
             ( ( >= list-sep ( vector-ref elmts high ) ) )
             ( ( set! high ( - high 1 ) )
              )
            )
           ( if ( <= low high )
             ( begin
               ( set! temp ( vector-ref elmts low ) )
               ( vector-set! elmts low ( vector-ref elmts high ) )
               ( vector-set! elmts high temp )
               ( set! low ( + low 1 ) )
               ( set! high ( - high 1 ) )
               ( display "Array -> " )
               ( display elmts )
               ( newline )
              )
            )
          )

         ( display "start ->" )
         ( display start )
         ( newline )
         ( display "high ->" )
         ( display high )
         ( newline )

         ( if ( < start high )
           ( Q start high )
          )

         ( if ( < low end )
           ( Q low end )
          )
        )
      )
    )
  )
